package cms.manage.template.value;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Slf4j
@Service
public class TplValueFactoryStrategy {
    @Autowired
    Map<String, TplValueStrategy> strategyConcurrentHashMap = new ConcurrentHashMap<>();

    public TplValueStrategy getStrategy(String component) {
        TplValueStrategy strategy = strategyConcurrentHashMap.get(component);
        if (strategy == null) {
            log.error("component {} no strategy defined", component);
            throw new RuntimeException("no strategy defined");
        }
        return strategy;
    }
}
